home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / VBASIC / MBUTTON.ZIP / MAIN.FRM (.txt) next >
Encoding:
Visual Basic Form  |  1996-10-24  |  2.1 KB  |  51 lines

  1. VERSION 4.00
  2. Begin VB.Form form1 
  3.    Caption         =   "Moving button example, by Alesh Mustar"
  4.    ClientHeight    =   3870
  5.    ClientLeft      =   4470
  6.    ClientTop       =   3075
  7.    ClientWidth     =   6135
  8.    Height          =   4275
  9.    Left            =   4410
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   3870
  12.    ScaleWidth      =   6135
  13.    Top             =   2730
  14.    Width           =   6255
  15.    Begin VB.CommandButton Command1 
  16.       Caption         =   "Click me, to find out the meaning of life..."
  17.       Height          =   765
  18.       Left            =   930
  19.       TabIndex        =   0
  20.       Top             =   600
  21.       Width           =   4365
  22.    End
  23.    Begin VB.Label Label1 
  24.       Caption         =   "Greetings to the members of VBBN && #visualbasic channel on Efnet!!!"
  25.       Height          =   255
  26.       Left            =   540
  27.       TabIndex        =   1
  28.       Top             =   1620
  29.       Width           =   5085
  30.    End
  31. Attribute VB_Name = "form1"
  32. Attribute VB_Creatable = False
  33. Attribute VB_Exposed = False
  34. Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  35.     'check if the command button is 600 pixels from the top of the form
  36.     If Command1.Top = 600 Then
  37.         'set the i value, from 600 to the form's height - 2 height's of the button
  38.         'so that the button doesn't go to much down, step Y Axis, per pixel
  39.         For i = 600 To form1.Height - 2 * Command1.Height Step Screen.TwipsPerPixelY
  40.             Command1.Top = i        'move the command button to position which = i
  41.         Next i  'repeat till i = the value assigned
  42.     Else    'if the button is not upstairs, it can only be downstairs
  43.         'set i value to form's height - 2 times height of the button to 600
  44.         'step Y Axis, per pixel but minus way so the button will move back up
  45.         For i = form1.Height - 2 * Command1.Height To 600 Step -Screen.TwipsPerPixelY
  46.             Command1.Top = i    'move the command button to position which = i
  47.         Next i  'repeat till i = the value assigned
  48.         
  49.     End If
  50. End Sub
  51.